package com.vpx.server.framework.enums;
/**
 * @author xx
 * @title: vpx
 * @module 
 * @description: 
 * @date 
 */
public enum MsgType {
	/**
	 * 枚举字段
	 */
	RESERVATION(0x00), REGISTER(0x01), REGISTER_RESP(0x02), HEARTBEAT(0x11), HEARTBEAT_RESP(0x12), OFFLINE(0x13),
    OFFLINE_RESP(0x14), PUSH(0x21), PUSH_RESP(0x22), PUSH_CHANGE_INFO(0x23), ROBBINGORDER(0x31), ROBBINGORDER_RESP(0x32), ORDER(0x33), DEL_ORDER(0x35),
    ORDER_RESP(0x34), ERROR(0xFF), SEAL_PUSH(0x36), SEAL_DELETE(0x37), SEAL_DELETE_RESP(0x38);

    private int code;

    private MsgType(int code) {
        this.code = code;
    }

    public int getValue() {
        return this.code;
    }

    public static MsgType convert(int code) {
    	int codeMax = 0xFF;
        if (code < 0 && code > codeMax) {
            return ERROR;
        }

        MsgType[] values = MsgType.values();
        for (MsgType msgType : values) {
            if (msgType.getValue() == code) {
                return msgType;
            }
        }
        return ERROR;
    }

}
